PEP8 Python test files
authorJeroen van der Heijden <jeroen@transceptor.technology>
Mon, 27 Aug 2018 11:34:39 +0000 (13:34 +0200)
committerJeroen van der Heijden <jeroen@transceptor.technology>
Mon, 27 Aug 2018 11:34:39 +0000 (13:34 +0200)
17 files changed:
test/data_google_finance.py
test/siridb-random-data.py
test/test_cluster.py
test/test_group.py
test/test_list.py
test/test_pipe_support.py
test/test_pool.py
test/test_select.py
test/test_series.py
test/test_syslog.py
test/test_user.py
test/testing/__init__.py
test/testing/client.py
test/testing/constants.py
test/testing/pipe_client.py
test/testing/series.py
test/testing/siridb.py

index b48ad9104da3bc3a2e9881c31b6f045281bcf812..2427dedc1780ccf83d0d18b4de31ef8ad4470035 100755 (executable)
@@ -7,6 +7,7 @@ URL = \
     'http://www.google.com/finance/getprices?' \
     'i={interval}&p={days}d&f=d,o,h,l,c,v&df=cpct&q={ticker}'
 
+
 def _data_to_csv(data, ticker, interval):
     lines = []
     series = None
@@ -55,6 +56,7 @@ async def get_google_finance_data(ticker, interval, days):
             content = await resp.text()
             return _data_to_csv(content, ticker, interval)
 
+
 async def save_google_finance_data(fn, ticker, interval, days):
     """Returns Google Finance Data in CSV format.
 
@@ -68,6 +70,7 @@ async def save_google_finance_data(fn, ticker, interval, days):
     with open(fn, 'w') as f:
         f.write(csv_data)
 
+
 async def print_google_finance_data(ticker, interval, days):
     """Prints Google Finance Data in CSV format.
 
@@ -76,7 +79,7 @@ async def print_google_finance_data(ticker, interval, days):
     :param days: The historical data period in days
     :return: None
     """
-    print (await get_google_finance_data(ticker, interval, days))
+    print(await get_google_finance_data(ticker, interval, days))
 
 if __name__ == '__main__':
     parser = argparse.ArgumentParser()
@@ -107,4 +110,3 @@ if __name__ == '__main__':
         ticker=args.ticker,
         interval=args.interval,
         days=args.days))
-
index 1e575ab820b5fa7da5cafda8014ff1957f7dfb34..53e29e3aaf75e4e31a3ba58a344a3ee569b7d3f2 100755 (executable)
@@ -466,7 +466,7 @@ Home-page: https://github.com/transceptor-technology/siridb-email-check
         if datetime.datetime.strptime(
                 args.start_date, '%Y-%m-%d') >= datetime.datetime.today():
             exit('start date must be a date before today.')
-    except:
+    except Exception:
         exit('invalid date: {}'.format(args.start_date))
 
     setup_logger(args)
index be46fec026cdb49433f455beccca174d236fbfab..aab5369d25673a15166dc8b5639e898e91c8d965 100644 (file)
@@ -63,6 +63,7 @@ class TestCluster(TestBase):
 
         return False
 
+
 if __name__ == '__main__':
     SiriDB.LOG_LEVEL = 'INFO'
     Server.HOLD_TERM = True
index f0e3b930e32e8eeca38e2374f3be0c019a83a890..4a5368701bbd7b2f4bb2d2a93e092783f1f6f7fe 100644 (file)
@@ -111,23 +111,28 @@ class TestGroup(TestBase):
             await self.client1.query('alter group `two` set expression /.2/'),
             {'success_msg': "Successfully updated group 'two'."})
 
-
         time.sleep(3)
 
         result = await self.client0.query('list series `a` & `two`')
         self.assertEqual(sorted(result.pop('series')), [['a2']])
 
         result = await self.client0.query('list series `a` | `two`')
-        self.assertEqual(sorted(result.pop('series')), [['a1'], ['a2'], ['b2'], ['c2']])
+        self.assertEqual(
+            sorted(result.pop('series')),
+            [['a1'], ['a2'], ['b2'], ['c2']])
 
         result = await self.client0.query('list series `a` ^ `two`')
-        self.assertEqual(sorted(result.pop('series')), [['a1'], ['b2'], ['c2']])
+        self.assertEqual(
+            sorted(result.pop('series')),
+            [['a1'], ['b2'], ['c2']])
 
         result = await self.client0.query('list series `a` - `two`')
         self.assertEqual(sorted(result.pop('series')), [['a1']])
 
         result = await self.client0.query('list series `a`, `two` - "c2"')
-        self.assertEqual(sorted(result.pop('series')), [['a1'], ['a2'], ['b2']])
+        self.assertEqual(
+            sorted(result.pop('series')),
+            [['a1'], ['a2'], ['b2']])
 
         result = await self.client0.query('list series `a`, `two` & "c2"')
         self.assertEqual(sorted(result.pop('series')), [['c2']])
@@ -169,6 +174,7 @@ class TestGroup(TestBase):
 
         return False
 
+
 if __name__ == '__main__':
     SiriDB.LOG_LEVEL = 'CRITICAL'
     Server.HOLD_TERM = True
index 5472fe388a8827322b9647c2ad13dd843a673e6c..154c0fa829237744209a84f37efcfa8cd57430de 100644 (file)
@@ -24,8 +24,8 @@ TIME_PRECISION = 's'
 class TestList(TestBase):
     title = 'Test list'
 
-    GEN_POINTS = functools.partial(gen_points, n=1, time_precision=TIME_PRECISION)
-
+    GEN_POINTS = functools.partial(
+        gen_points, n=1, time_precision=TIME_PRECISION)
 
     @default_test_setup(1, time_precision=TIME_PRECISION)
     async def run(self):
@@ -96,7 +96,8 @@ class TestList(TestBase):
         await self.client0.query('alter database set list_limit 5000')
         with self.assertRaisesRegexp(
                 QueryError,
-                'Limit must be a value between 0 and 5000 but received: 6000.*'):
+                'Limit must be a value between 0 and 5000 '
+                'but received: 6000.*'):
             await self.client0.query(
                 'list series limit 6000')
 
index bde86f63e4ae65f5850f197886a29afab77f921c..680382962054908af02863a7e19b9cf0a8aae5f7 100644 (file)
@@ -41,10 +41,10 @@ DATA = {
 if os.path.exists(PIPE_NAME):
     os.unlink(PIPE_NAME)
 
+
 class TestPipeSupport(TestBase):
     title = 'Test pipe support object'
 
-
     @default_test_setup(1, pipe_name=PIPE_NAME)
     async def run(self):
 
index 420cc7381641353626e559d9823a187b678a65fb..d42078c044add24bd5f5eb73d93fb7e875462570 100644 (file)
@@ -27,7 +27,6 @@ class TestPool(TestBase):
             await client.insert_some_series(series, n=0.01, timeout=timeout)
             await asyncio.sleep(1.0)
 
-
     @default_test_setup(4)
     async def run(self):
 
index 6ae91bd12e89513c68568df09023934a1b9d8b2b..4031e4e05b39854be9b308e447160869cfcad4a4 100644 (file)
@@ -218,7 +218,7 @@ class TestSelect(TestBase):
         self.assertEqual(
             await self.client0.query(
                 'select filter(/l.*/) from * where type == string'),
-                {'log': [p for p in DATA['log'] if re.match('l.*', p[1])]})
+            {'log': [p for p in DATA['log'] if re.match('l.*', p[1])]})
 
         self.assertEqual(
             await self.client0.query(
index 14dd090ebfa01ec1a8036726cd36e1c98c27daec..37b35945bd7e024bacdc07708bfe2c36026dd1c9 100644 (file)
@@ -20,7 +20,9 @@ from testing import UserAuthError
 
 
 PI = 'ԉ'
-Klingon = '     qajunpaQHeylIjmo’ batlh DuSuvqang charghwI’ ‘It.'
+Klingon = '     ' + \
+    'qajunpaQHeylIjmo’ batlh DuSuvqang charghwI’ ‘It.'
+
 
 class TestSeries(TestBase):
     title = 'Test series object'
index 5c8416763aa5e5adcf9189c5946497d8b95ba87e..16f9907573cc539b6c7aacd3bbdeea3ba7877a21 100644 (file)
@@ -42,7 +42,6 @@ MTCH = re.compile(
 class TestSyslog(TestBase):
     title = 'Test with syslog data'
 
-
     async def insert_syslog(self, batch_size=100):
 
         with open(SYSLOG, 'r') as f:
@@ -85,6 +84,7 @@ class TestSyslog(TestBase):
 
         return False
 
+
 if __name__ == '__main__':
     SiriDB.LOG_LEVEL = 'CRITICAL'
     Server.HOLD_TERM = True
index 97802afbbf60995e0fd36d8799d242ce67e10c98..bc39d0a173ebf5ba9ecb0a922f0970179c70acb3 100644 (file)
@@ -47,14 +47,19 @@ class TestUser(TestBase):
                 'Password should be at least 4 characters.'):
             await self.client0.query('create user "aa" set password "123" ')
 
-        result = await self.client0.query('create user "sasientje" set password "blabla" ')
-        self.assertEqual(result.pop('success_msg'), "Successfully created user 'sasientje'.")
+        result = await self.client0.query(
+            'create user "sasientje" set password "blabla" ')
+        self.assertEqual(
+            result.pop('success_msg'),
+            "Successfully created user 'sasientje'.")
 
         result = await self.client0.query('list users where access < modify ')
         self.assertEqual(result.pop('users'), [['sasientje', 'no access']])
 
         result = await self.client0.query('grant modify to user "sasientje" ')
-        self.assertEqual(result.pop('success_msg'), "Successfully granted permissions to user 'sasientje'.")
+        self.assertEqual(
+            result.pop('success_msg'),
+            "Successfully granted permissions to user 'sasientje'.")
 
         await self.db.add_replica(self.server1, 0)
         await self.assertIsRunning(self.db, self.client0, timeout=10)
@@ -66,14 +71,22 @@ class TestUser(TestBase):
         result = await self.client1.query('list users where access < full ')
         self.assertEqual(result.pop('users'), [['sasientje', 'modify']])
 
-        result = await self.client1.query('revoke write from user "sasientje" ')
-        self.assertEqual(result.pop('success_msg'), "Successfully revoked permissions from user 'sasientje'.")
+        result = await self.client1.query(
+            'revoke write from user "sasientje" ')
+        self.assertEqual(
+            result.pop('success_msg'),
+            "Successfully revoked permissions from user 'sasientje'.")
 
-        result = await self.client1.query('grant show, count to user "sasientje"')
-        result = await self.client1.query('list users where access < modify ')
-        self.assertEqual(result.pop('users'), [['sasientje', 'alter, count, drop and show']])
+        result = await self.client1.query(
+            'grant show, count to user "sasientje"')
+        result = await self.client1.query(
+            'list users where access < modify ')
+        self.assertEqual(
+            result.pop('users'),
+            [['sasientje', 'alter, count, drop and show']])
 
-        result = await self.client1.query('create user "pee" set password "hihihaha" ')
+        result = await self.client1.query(
+            'create user "pee" set password "hihihaha" ')
         time.sleep(0.1)
         result = await self.client0.query('list users where name ~ "p"')
         self.assertEqual(result.pop('users'), [['pee', 'no access']])
@@ -85,9 +98,11 @@ class TestUser(TestBase):
         with self.assertRaisesRegexp(
                 QueryError,
                 "Password should be at least 4 characters."):
-            result = await self.client1.query('alter user "sasientje" set password "dag" ')
+            result = await self.client1.query(
+                'alter user "sasientje" set password "dag" ')
 
-        result = await self.client1.query('alter user "sasientje" set password "dagdag"')
+        result = await self.client1.query(
+            'alter user "sasientje" set password "dagdag"')
 
         await self.server0.start(sleep=35)
 
@@ -107,12 +122,15 @@ class TestUser(TestBase):
             result = await self.client0.insert({'no access test': [[1, 1.0]]})
 
         result = await self.client1.query('drop user "sasientje" ')
-        self.assertEqual(result.pop('success_msg'), "Successfully dropped user 'sasientje'.")
+        self.assertEqual(
+            result.pop('success_msg'),
+            "Successfully dropped user 'sasientje'.")
         time.sleep(0.1)
 
         for client in (self.client0, self.client1, self.client2):
             result = await client.query('count users')
-            self.assertEqual(result.pop('users'), 2, msg='Expecting 2 users (iris and pee)')
+            self.assertEqual(
+                result.pop('users'), 2, msg='Expecting 2 users (iris and pee)')
 
         result = await self.client0.query('count users where name == "pee"')
         self.assertEqual(result.pop('users'), 1, msg='Expecting 1 user (pee)')
@@ -130,22 +148,26 @@ class TestUser(TestBase):
         with self.assertRaisesRegexp(
                 QueryError,
                 "^User name contains illegal characters.*"):
-            result = await self.client1.query('alter user "pee" set name " p " ')
+            result = await self.client1.query(
+                'alter user "pee" set name " p " ')
 
         with self.assertRaisesRegexp(
                 QueryError,
                 "User 'iris' already exists."):
-            result = await self.client1.query('alter user "pee" set name "iris" ')
+            result = await self.client1.query(
+                'alter user "pee" set name "iris" ')
 
         with self.assertRaisesRegexp(
                 QueryError,
                 "User 'iris' already exists."):
-            result = await self.client1.query('alter user "pee" set name "iris" ')
+            result = await self.client1.query(
+                'alter user "pee" set name "iris" ')
 
         with self.assertRaisesRegexp(
                 QueryError,
                 "Cannot find user: 'Pee'"):
-            result = await self.client1.query('alter user "Pee" set name "PPP" ')
+            result = await self.client1.query(
+                'alter user "Pee" set name "PPP" ')
 
         result = await self.client1.query('alter user "pee" set name "Pee"')
         self.assertEqual(
index 54a54e7341c35be72a4771b1ef333284ea946234..fe23f73f4f7ffb1e296a9650a7c6cb1997c50cb6 100644 (file)
@@ -43,4 +43,4 @@ def run_test(test, loglevel='CRITICAL'):
     assert isinstance(test, TestBase)
     loop = asyncio.get_event_loop()
     cleanup()
-    loop.run_until_complete(_run_test(test, loglevel))
\ No newline at end of file
+    loop.run_until_complete(_run_test(test, loglevel))
index b5d8f375181cd2e6c53a83f36eb3d3439cdabdac..686d865085537a781201857e3451a4f0252b2380 100644 (file)
@@ -73,4 +73,3 @@ class Client:
 
         for s in series[:n]:
             s.commit_points()
-
index 8ec4aca174e053e1737c34a39799015d0570a8d6..14223bcccae0a74c49bd53d5fc8bc7098a9dd994 100644 (file)
@@ -2,6 +2,11 @@ BUILDTYPE = 'Debug'
 TEST_DIR = './testdir'
 SIRIDBC = '../{BUILDTYPE}/siridb-server'
 ADMIN = '/usr/local/bin/siridb-admin'
-# VALGRIND = 'valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --track-origins=yes -v '
+VALGRIND = 'valgrind' + \
+  ' --tool=memcheck' + \
+  ' --leak-check=full' + \
+  ' --show-leak-kinds=all' + \
+  ' --track-origins=yes' + \
+  ' -v '
 VALGRIND = 'valgrind --tool=memcheck '
 MAX_OPEN_FILES = 512    # Default value is 32768 but with valgrind 512 is max
index 9b90eafd351aeaa31c2869a6456ced35dbc2e975..4164e7fe6d9724aa900182df9a9c64f3af860619 100644 (file)
@@ -25,5 +25,3 @@ class PipeClient(SiriDBAsyncConnection):
             raise exc
         else:
             self._protocol.on_authenticated()
-
-
index dd71d8145a0b2fa0467522f00d6179189d769899..bbf3c9a08c6402e5697e98cad75aedb585b84a38 100644 (file)
@@ -14,4 +14,3 @@ class Series:
             for point in self._points:
                 self.points.append(point)
             self._points = None
-
index 51445f371b01fb447389408c4b5e9870dde865fe..077c3a5f7c833521693a33428d13bb18e34c2fe5 100644 (file)
@@ -131,5 +131,3 @@ class SiriDB:
 
         if sleep:
             await asyncio.sleep(sleep)
-
-